package tech.aistar.mapper.trading;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tech.aistar.entity.trading.GoodsDetails;

import java.util.List;

/**
 * @author Ace
 * @version 1.0
 * @descriiption:本类用来演示:商品详情接口
 * @date 2019/9/27 0027.
 */
public interface GoodsDetailsMapper {
/**
 * 查--查所有
 */
@Select("select*from goods_details")
    List<GoodsMapper> findAll();

/**
 *查--根据id查
 */
@Select("select*from goods_details where good_id=#{value}")
GoodsDetails findById(Integer goodsId);

/**
 *改--修改更新属性
 */
@Update("update goods_details set goods_id=#{goodsId},brand=#{brand},type=#{type},varieties=#{varieties},weight=#{weight}," +
        "apply_phase=#{applyPhase},remain_time=#{remainTime},apply_size=#{applySize},taste=#{taste},origin_place=#{originPlace}," +
        "manufacturer_address=#{manufacturerAddress},manufacturer_name=#{manufacturerName},size=#{size}")
    void update(GoodsDetails goodsDetails);

    /**
     * 删----通过设置status的值达到删除某个数据,不用真的删除
     * @param id
     */
    @Update("update goods_details set status=1 where id=#{value}")
    void delById(Integer id);

    /**
     * 添加商品详情
     */
    @Insert("insert into goods_details(goods_id,brand,type,varieties,weight,apply_phase,remain_time,apply_size,taste,origin_place," +
            "manufacturer_address,manufacturer_name,size) values(#{goodsId},#{brand},#{type},#{varieties},#{weight},#{applyPhase},#{remainTime}," +
            "#{applySize},#{taste},#{originPlace},#{manufacturerAddress},#{manufacturerName},#{size})")
    void save(GoodsDetails goodsDetails);
}
